import { pcaa, pca } from 'area-data'
function toArray(map) {
	let result = []
	for (let key in map) {
		result.push({
			label: map[key],
			value: map[key],
			code: key
		})
	}
	return result
}
export function getProvinceList() {
	return toArray(pca['86'])
}

export function getCityList(provinceCode) {
	return toArray(pca[provinceCode])
}

export function getAreaList(cityCode) {
	return toArray(pcaa[cityCode])
}

export function getCombinationList() {
	let provinceList = getProvinceList()
	provinceList.forEach((province) => {
		let cityList = getCityList(province.code)
		province['children'] = cityList
		cityList.forEach((city) => {
			city['children'] = getAreaList(city.code)
		})
	})
	return provinceList
}
